package logic

import (
	"context"
	"errors"
	"user_srv/internal/dao"

	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type CreateTrustedDevicesLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCreateTrustedDevicesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTrustedDevicesLogic {
	return &CreateTrustedDevicesLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CreateTrustedDevicesLogic) CreateTrustedDevices(in *user.CreateTrustedDevicesRequest) (*user.CreateTrustedDevicesResponse, error) {
	// todo: add your logic here and delete this line
	devices, err := dao.CreateTrustedDevices(in)
	if err != nil {
		return nil, errors.New("信任设备添加失败")
	}
	return &user.CreateTrustedDevicesResponse{
		Id: int64(devices.Id),
	}, nil
}
